#/bin/zsh
echo "Creating Database..."
rm -rf ~/.sys/db/files.db
mkdir ~/.sys/db
sqlite3 ~/.sys/db/files.db "CREATE TABLE files (location varchar(255))"

echo "Reading Directories..."
sqlite3 ~/.sys/db/files.db "DELETE FROM files; vacuum"

# Simply add your directory here!

for searchpath in /Applications ~/Applications /Developer/Applications; do
	find ${searchpath} -iname *.app -maxdepth 3 -type d | grep -v "Contents" | while read app; do 
		echo $app
		sqlite3 ~/.sys/db/files.db "INSERT INTO files VALUES('${app}')"
	done
done
